Skip to content

Add Python project base template#3

Merged
samhodgkinson merged 1 commit into
mainfrom
claude/python-docker-template-QWs3s
Jun 6, 2026
Merged

Add Python project base template#3
samhodgkinson merged 1 commit into
mainfrom
claude/python-docker-template-QWs3s

Conversation

@samhodgkinson

Copy link
Copy Markdown
Owner

Complete Python project base template, reviewed and CI green.

What's included

  • Docker — multi-stage build (dev for dev containers, prod for deployment), two-layer builder pattern for correct hatchling builds and optimal layer caching
  • Dev container — VS Code devcontainer from the dev Dockerfile target; non-root devuser, named .venv volume, auto-syncs on create
  • uv + pyproject.toml — all project config in one file: Ruff, Mypy (strict), pytest, bandit, pip-audit
  • VS Code — settings, recommended extensions, and debug launch configs pre-wired (Ruff format-on-save, Mypy extension, pytest panel)
  • GitHub Actions CI — lint (Ruff + Mypy), tests with coverage, pip-audit dependency scan, Docker build (scoped GHA cache per target)
  • GitHub Actions CodeQL — Python SAST on push/PR/weekly
  • CLAUDE.md + slash commands — AI context and /test, /lint, /security, /build project commands
  • uv.lock committed for reproducible installs

Review fixes applied

  • pythonpath = ["src"] added so bare pytest works without editable install
  • Coverage flags removed from addopts — explicit in CI only
  • Pylance set to "off" — defers to mypy extension (was "basic", inconsistent with strict mypy)
  • Bandit removed from CI — CodeQL covers SAST; bandit kept for local use
  • Docker GHA cache scoped per target (scope=dev / scope=prod)
  • enable-cache: true on all setup-uv steps
  • Dead targets key removed from [tool.bandit]
  • dev compose service removed (was a pytest runner with a misleading name)
  • Dev Dockerfile stage: non-root devuser added, redundant build-time uv sync removed
  • Readme rewritten for container-first, zero-Python audience

https://claude.ai/code/session_01TiXyp1vCmxNP2ewP4s1TGH


Generated by Claude Code

README:
- Lead with VS Code + Docker as the only prerequisites
- Step-by-step: Use Template → clone → Reopen in Container → pytest
- Remove local uv install instructions as primary path
- Explain what the editor does automatically (format on save, type errors)
- Cover adding dependencies, adapting for a new project, and CI checks
- Production Docker usage moved to its own section, not buried in Quick Start

CLAUDE.md:
- Clarify the dev-container-first design intent
- Document the two-step builder pattern and why it exists
- Note that pythonpath = ["src"] makes tests work without editable install
- Explain why bandit is absent from CI (CodeQL covers SAST)

https://claude.ai/code/session_01TiXyp1vCmxNP2ewP4s1TGH
@samhodgkinson samhodgkinson merged commit 4360458 into main Jun 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants